import {createStackNavigator} from '@react-navigation/stack';
import {NavigationContainer} from '@react-navigation/native';
import {useTheme} from '@gluestack-ui/themed';
import type {ApplicationStackParamList} from '@/types/navigation';
import { navigationRef } from './RootNavigation';

import routes from "./routes";

const Stack = createStackNavigator<ApplicationStackParamList>();

function ApplicationNavigator() {
    const {theme} = useTheme();
    console.log("主题", theme)
    return (
        <NavigationContainer ref={navigationRef}>
            <Stack.Navigator initialRouteName="Dashboard">
                {routes.map((route, index) => (
                    <Stack.Group screenOptions={route.screenOptions} key={index}>
                        {
                            route.children.map(r => (
                                <Stack.Screen
                                    name={r.name}
                                    component={r.component}
                                    options={r.options}
                                    key={r.name}
                                />
                            ))
                        }
                    </Stack.Group>
                ))}
            </Stack.Navigator>
        </NavigationContainer>
    );
}

export default ApplicationNavigator;
